/**
 * 
 */
package utilities;

import java.io.*;

/**
 * @author Marcin
 *
 */
public final class FileComparer {

	public static boolean compareFiles(final String fname1, final String fname2)
	{
		try 
		{
			FileInputStream fin1 = new FileInputStream(new File(fname1));
			FileInputStream fin2 = new FileInputStream(new File(fname2));	
			int c1 = fin1.read();
			int c2 = fin2.read();
			
			while (c1 != -1 && c2 != -1)
			{
				if (c1 != c2)
					return false;
				
				c1 = fin1.read();
				c2 = fin2.read();
			}
			
			fin1.close();
			fin2.close();
			
			return (c1 == -1 && c2 == -1) ? true : false;
		}
		
		catch (Exception e) 
		{
			return false;
		} 
	}
}
